<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{if $userFlg == 1}-->质检入库<!--{elseif $userFlg == 2}-->上车扫描<!--{else}-->下车扫描<!--{/if}--></title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<div class="container">

    <div class="comm_content">
            <div class="search-box">
                <div style="position:relative">
                    <form class="form-inline" id="search_form" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span>配送日期：<input type="text"  readonly class="form-control input-sm" style="width:100px" value="<!--{$currentDate|default:''}-->" name="send_date" id="send_date"></span>
                                    <span>
                                        配送开始时间：
                                        <select name="send_start_time" id="send_start_time" class="form-control input-sm" style="width:100px;">
                                            <option value="">请选择</option>
                                            <!--{foreach from = $sendStartTime_array  key=myId item = val}-->
                                            <!--{if $myId == 0}-->
                                            <option value="<!--{$val.itemName}-->" selected><!--{$val.itemName}--></option>
                                            <!--{/if}-->
                                            <option value="<!--{$val.itemName}-->"><!--{$val.itemName}--></option>
                                            <!--{/foreach}-->


                                        </select>
                                    </span>
                                    <input type="hidden" value="" id="send_start_time_detail" name="send_start_time_detail">

                                    <span>
                                        配送结束时间：
                                        <select name="send_start_time_end" id="send_start_time_end" class="form-control input-sm" style="width:100px;">
                                            <option value="">请选择</option>
                                            <!--{foreach from = $sendEndTime_array item = val}-->
                                            <!--{if $userFlg == 3}-->
                                                <!--{if $val.itemName == $end_time}-->
                                                <option value="<!--{$val.itemName}-->" selected><!--{$val.itemName}--></option>
                                                <!--{/if}-->
                                            <!--{/if}-->
                                            <option value="<!--{$val.itemName}-->"><!--{$val.itemName}--></option>
                                            <!--{/foreach}-->
                                        </select>
                                    </span>
                                    <input type="hidden" value="" id="send_start_time_end_detail" name="send_start_time_end_detail">

                                    <span>
                                       配送城市：
                                        <select id="cityID" name="cityID" class="form-control input-sm" style="width:100px;">
                                            <option value="" selected="">请选择</option>                                            　　
                                        </select>
                                    </span>

                                    <span>
                                        配送站：
                                        <select name="distribution_id" id="distribution_id" class="form-control input-sm" style="width:110px;">
                                            <option value="">请选择</option>
                                        </select>
                                    </span>

                                    <span><input type="button" onclick="voucherGoods.search();" class="btn btn-primary" value="查询"></span>
                                    <span><input type="button" onclick="voucherGoods.load();" class="btn btn-warning" value="重置"></span>

                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <div class="panel panel-default"  >

                <div class="panel-heading">订单商品</div>

                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th width="100" style="text-align: center;">配送日期</th>
                        <th width="100">站点</th>
                        <th width="100">审核</th>
                        <th width="100">已打印生产单</th>
                        <!--{if $userFlg == 1}-->
                        <th width="100">入库</th>
                        <th width="100">未入库</th>
                        <!--{/if}-->
                        <!--{if $userFlg == 2}-->
                        <th width="100">入库</th>
                        <th width="100">上车</th>
                        <th width="100">未入库</th>
                        <th width="100">未上车</th>
                        <!--{/if}-->
                        <!--{if $userFlg == 3}-->
                        <th width="100">入库</th>
                        <th width="100">下车</th>
                        <th width="100">未入库</th>
                        <th width="100">未下车</th>
                        <!--{/if}-->
                    </tr>
                    </thead>
                    <tbody id="goods_list"></tbody>
                </table>

            </div>
            <div class="search-box" id = "bill_goods_input" style="background:white;border: 0px solid #c9c9c9">
                <div style="position:relative">
                    <form class="form-inline" id="item_form" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span><span class="red">*</span>条码：<input type="text" class="form-control input-sm" style="width:210px" value="" name="bill_goods_no" id="bill_goods_no" placeholder="请输入订单商品流水号,并按回车键"></span>
                                    <span>累计扫描数量：<input type="text" class="form-control input-sm" style="width:180px" value="0" readonly name="lineCount" id="lineCount" ></span>
                                    <span>质检人：<input type="text" class="form-control input-sm" style="width:180px" value="<!--{$voucher_operator}-->" readonly name="voucher_operator" id="voucher_operator" ></span>

                                </td>
                                <td style="display: none;" id="voiceError"></td>
                                <td style="display: none;" id="seepOperate"></td>
                                <td style="display: none;" id="multicake"></td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>


            <div class="panel panel-default" id="bill_goods_voucher" style="display:none;" >
                <div class="panel-heading"><!--{if $userFlg == 1}-->入库商品<!--{else}-->出库商品<!--{/if}--></div>
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th width="180" style="text-align: center;">商品SKU</th>
                        <th width="140" style="text-align: center;">流水号</th>
                        <th width="*">品名</th>
                        <th width="140" id="distribution_technicia_add" style="display:none">配送员</th>
                        <th width="140">配送站</th>
                        <th width="130" style="text-align: center;">配送日期</th>
                        <th width="120" style="text-align: center;">配送开始时间</th>
                        <th width="120" style="text-align: center;">配送结束时间</th>
                    </tr>
                    </thead>
                    <tbody id="goods_info"></tbody>
                </table>

            </div>
            <!--{if $userFlg == 3}-->

            <div class="panel panel-default"  style="display:block;width:1200px" >
                <div class="panel-heading">非本站订单操作记录</div>
                <table class="table table-bordered" id="logInfo">
                    <thead>
                    <tr >
                        <th width="180" style="text-align: center;" >订单编号</th>
                        <th width="180" style="text-align: center;">订单商品流水号</th>
                        <th width="140" style="text-align: center;">下错站点</th>
                        <th width="140"style="text-align: center;">正确站点</th>
                        <th width="140" style="text-align: center;">操作者</th>
                        <th width="*" style="text-align: center;">日志</th>

                    </tr>
                    </thead>
                    <tbody>
                    <!--{foreach from=$log_query item=logQuery}-->
                    <tr style="text-align: center" >
                        <td><!--{$logQuery->bill_code}--></td>
                        <td><!--{$logQuery->bill_goods_no}--></td>
                        <td><!--{$logQuery->distribution_id_f}--></td>
                        <td><!--{$logQuery->distribution_id_t}--></td>
                        <td><!--{$logQuery->creator}--></td>
                        <td><!--{$logQuery->content}--></td>
                    </tr>
                    <!--{/foreach}-->
                    </tbody>
                </table>

            </div>
            <!--{/if}-->
        </div>

</div>
<div  style=" height:0px; overflow:hidden;">
<input type="button" id="hdb">
</div>
<audio id="audio" controls="controls" autoplay="autoplay" style="display: none;"></audio>

<script type="text/javascript">

var voucherGoods = {

    userFlg:<!--{$userFlg}-->, //区分质检入库 、上车扫描 、下车扫描
    bill_goods_no:'',//订单生产流水号
    forget_operate_flow:'',//漏操作流程
    //查询生成订单商品生产信息
    search: function() {
        $("#goods_list").html('');
        $('#goods_info').html('');//待录入商品信息部分置空
        var send_date = $("#send_date").val();
        if(send_date == ""){
            E.alert("配送日期不能为空");
        }
        var formValues = E.getFormValues("search_form");

        //查询时把时间记录下来
        var send_start_time_detail = $('#send_start_time').val();
        var send_start_time_end_detail = $('#send_start_time_end').val();
        $('#send_start_time_detail').val(send_start_time_detail);
        $('#send_start_time_end_detail').val(send_start_time_end_detail);

        E.ajax_post({
            url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=1&userFlg="+voucherGoods.userFlg,
            data:{
                formValues:formValues
            },
            call: "voucherGoods.addLineCallBack" //根据查询信息成功回调函数
        });

    },

    //查询信息成功回调
    addLineCallBack: function (response){

        if (response.code == 200) {

            //配送时间
            var send_start_time = $('#send_start_time_detail').val()?$('#send_start_time_detail').val():'';
            var send_start_time_end = $('#send_start_time_end_detail').val()?$('#send_start_time_end_detail').val():'';
            var data = response.data;//返回入库单数组
            var billGoodsNum = data.length;
            for(var i=0;i<billGoodsNum;i++){ //参数 1、审核数量  2、打印数 3、入库数 4、上车数 5、下车数 6、未入库 7、未上车 8、未下车
                var html = '<tr class = "trData"  id="goods_line_' + data[i].distribution_id + '">';
                html += '<td style="text-align: center;">' + data[i].send_date + '</td>';
                if( data[i].distribution_name ){
                    html += '<td>' + data[i].distribution_name + '</td>';
                }else{
                    html += '<td>配送站未分配</td>';
                }

                html += '<td><a onclick="voucherGoods.detail( 1,'+ "'"+data[i].send_date+"'" +  ','+ data[i].distribution_id +',' + "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' +  data[i].bill_goods_num + '</a></td>';

                html += '<td><a onclick="voucherGoods.detail( 2,'+ "'"+data[i].send_date+"'"  + ',' + data[i].distribution_id + ','  +  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + data[i].print_num + '</a></td>';

                <!--{if $userFlg == 1}-->

                html += '<td><a onclick="voucherGoods.detail( 3,'+ "'"+data[i].send_date+"'" + ','  + data[i].distribution_id + ',' + "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + data[i].voucher_num + '</a></td>';

                html += '<td><a onclick="voucherGoods.detail( 6,'+ "'"+data[i].send_date+"'" + ',' + data[i].distribution_id + ','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + (data[i].bill_goods_num - data[i].voucher_num) + '</a></td>';
                <!--{/if}-->

                <!--{if $userFlg == 2}-->
                html += '<td><a onclick="voucherGoods.detail( 3,'+ "'"+data[i].send_date+"'" + ','  + data[i].distribution_id + ','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + data[i].voucher_num + '</a></td>';
                html += '<td><a onclick="voucherGoods.detail( 4,'+ "'"+data[i].send_date+"'" + ','  + data[i].distribution_id + ','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + data[i].warehouse_num + '</a></td>';
                html += '<td><a onclick="voucherGoods.detail( 6,'+ "'"+data[i].send_date+"'" + ','  + data[i].distribution_id +','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + (data[i].bill_goods_num - data[i].voucher_num) + '</a></td>';
                html += '<td><a onclick="voucherGoods.detail( 7,'+ "'"+data[i].send_date+"'" + ','  + data[i].distribution_id +','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + (data[i].bill_goods_num - data[i].warehouse_num) + '</a></td>';
                <!--{/if}-->

                <!--{if $userFlg == 3}-->
                html += '<td><a onclick="voucherGoods.detail( 3,'+ "'"+data[i].send_date+"'" + ',' + data[i].distribution_id +','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + data[i].voucher_num + '</a></td>';
                html += '<td><a onclick="voucherGoods.detail( 5,'+ "'"+data[i].send_date+"'" + ',' + data[i].distribution_id + ','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + data[i].busScan_num + '</a></td>';
                html += '<td><a onclick="voucherGoods.detail( 6,'+ "'"+data[i].send_date+"'" + ','  + data[i].distribution_id + ','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + (data[i].bill_goods_num - data[i].voucher_num) + '</a></td>';
                html += '<td><a onclick="voucherGoods.detail( 8,'+ "'"+data[i].send_date+"'" + ','  + data[i].distribution_id + ','+  "'"+send_start_time + "'" +',' + "'"+send_start_time_end + "'" +')" href="javascript: void(0);">' + (data[i].bill_goods_num - data[i].busScan_num) + '</a></td>';
                <!--{/if}-->

                html += '</tr>';
                $('#goods_list').prepend( html );
            }

            //$('#bill_goods_input').show();//订单生产流水号部分显示
            $('#bill_goods_voucher').show();//待录入商品信息部分显示
            $('#bill_goods_no').val('').focus();


        } else {
            //$('#bill_goods_input').hide();
            $('#bill_goods_voucher').hide();
            E.alert(response.message);

        }

    },

    //通过订单流水号查询订单
    searchBillGoodsInfo:function( bill_goods_no ){

        var formValues = E.getFormValues("search_form");
        E.ajax_post({
            url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=2&userFlg="+voucherGoods.userFlg,
            data:{formValues:formValues,bill_goods_no:bill_goods_no},
            call: "voucherGoods.infoAddLineCallBack"
        });
    },


    //根据条码获取商品信息成功回调
    infoAddLineCallBack: function ( response ){

        //add by  20141030allen.qiang FUN-BK-0016-订单下错站处理 strt
        // 刷新非本站订单操作记录
        if (response.code == 404) {
            E.ajax_post({
                url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=8",
                data:{billGoodsNo:1},
                call:function(data){
                    var date=data.message;
                    var logNum = date.length;
                    $("#logInfo tbody tr").remove();
                    for(var i=0;i<logNum;i++){
                        var html="<tr style='text-align: center'>";
                                html+="<td>"+date[i]['bill_code']+"</td>";
                                html+= "<td>"+date[i]['bill_goods_no']+"</td>";
                                html+= "<td>"+date[i]['distribution_id_f']+"</td>";
                                html+="<td>"+date[i]['distribution_id_t']+"</td>";
                                html+= "<td>"+date[i]['creator']+"</td>";
                                html+= "<td>"+date[i]['content']+"</td>";
                            html+= "</tr>";
                        $("#logInfo").append(html);
                     }


                }
            });

        }
        //add by  20141030allen.qiang FUN-BK-0016-订单下错站处理 end


        if (response.code == 200) { //与头查询条件匹配
            $('#goods_list').html('');
            //==================重新加载获得订单信息start================
            var formValues = E.getFormValues("search_form");

            //查询时把时间记录下来
            var send_start_time_detail = $('#send_start_time').val();
            var send_start_time_end_detail = $('#send_start_time_end').val();
            $('#send_start_time_detail').val(send_start_time_detail);
            $('#send_start_time_end_detail').val(send_start_time_end_detail);

            E.ajax_post({
                url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=1&userFlg="+voucherGoods.userFlg,
                data:{
                    formValues:formValues
                },
                call: "voucherGoods.addLineCallBack" //根据查询信息成功回调函数
            });

            //==================重新加载获得订单信息end================

            var data = response.data;//返回入库单数组
            var html = '<tr class = "trData" id="goods_line_' + data[0].bill_goods_no + '">';

            //当data[0].distribution_technician_audio配送员有值时为下车扫描，且不为空报配送员
            if( data[0].distribution_technician_audio){ //自动播放配送员

                html += '<td style="display: none;"><audio controls="controls" autoplay="autoplay"><source src="' + data[0].distribution_technician_audio + '"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio></td>';
            }else{  //自动播放配送站
                var Media = document.getElementById("audio");
                $('#audio').attr('src',data[0].distribution_audio);
                Media.play();
//                html += '<td style="display: none;"><audio id="audio" controls="controls" autoplay="autoplay" src="' + data[0].distribution_audio + '" ></audio></td>';
                //html += '<td style="display: none;"><audio id="Media" controls="controls" autoplay="autoplay"><source src="' + data[0].distribution_audio + '"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio></td>';
            }

            if( voucherGoods.userFlg == 1 || voucherGoods.userFlg == 2){ //质检入库 上车扫描 一个订单多个商品 报语音
                if( data[0].billGoods_count > 1){

                    var Media = document.getElementById("audio");

                    Media.addEventListener("ended",voucherGoods.audioPlay, false);

                }
            }
//                if( voucherGoods.userFlg == 1 || voucherGoods.userFlg == 2){ //质检入库 上车扫描 一个订单多个商品 报语音
//                    if( data[0].billGoods_count > 1){
//                        html += '<td style="display: none;"><audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/multicake.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio></td>';
//                    }
//                }
            html += '<td style="text-align: center;">' + data[0].product_code + '</td>';
            html += '<td style="text-align: center;">' + data[0].bill_goods_no + '</td>';
            html += '<td>' + data[0].goods_name + '</td>';
            if( voucherGoods.userFlg == 3 ){
                html += '<td>' + data[0].distribution_technicia + '</td>';
            }
            html += '<td>' + data[0].distribution_name + '</td>';
            html += '<td style="text-align: center; ">' + data[0].send_date + '</td>';
            html += '<td style="text-align: center;">' + data[0].send_start_time + '</td>';
            html += '<td style="text-align: center;">' + data[0].send_end_time + '</td>';
            html += '</tr>';
            $('#goods_info').prepend( html );

            if(voucherGoods.userFlg == 3){ //下车扫描显示配送员
                $('#distribution_technicia_add').show();
            }
            $('#lineCount').val(parseInt($('#lineCount').val()) + 1);
            $('#goods_line_'+data[0].bill_goods_no).css('background-color','#00ff00');

            if( voucherGoods.userFlg == 1){ //质检入库
                E.alert('质检入库成功',2);
            }else if( voucherGoods.userFlg == 2){ //上车扫描
                E.alert('上车扫描成功',2);
            }else{
                E.alert('下车扫描成功',2);
            }

            $('#bill_goods_no').val('').focus();

        } else if( response.code == 201 ){ //与头查询条件不匹配 语音报错

            E.alert(response.message);
            //mod yim.hu 20141119 FUN-BK-0032 切换语音 --start
            	//var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/error.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
            if( voucherGoods.userFlg == 2){
            	var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/shangcuozhan.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
            
            }else{
             	var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/error.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
            
            }           	
            //mod yim.hu 20141119 FUN-BK-0032 切换语音 --end
            $('#voiceError').html(item);
            //del by 20141118allen.qiang FUN-BK-0031 入库上下车扫描优化 start
            //$('#bill_goods_no').val('').focus();
            //del by 20141118allen.qiang FUN-BK-0031 入库上下车扫描优化 end
            //add by 20141118allen.qiang FUN-BK-0031 入库上下车扫描优化 start
            $('#bill_goods_no').val('');
            $('#hdb').focus();
            //add by 20141118allen.qiang FUN-BK-0031 入库上下车扫描优化 end
        }else if( response.code == 202 ){  //生产后 or 质检后 直接下车扫描 报漏操作

            var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/seepOperate.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
            $('#seepOperate').html(item);

            voucherGoods.bill_goods_no = response.data.bill_goods_no;
            voucherGoods.forget_operate_flow = response.data.para;
            if( response.data == ''){
                E.alert( response.message,3 );
            }else{
                //短信提示站长
                E.ajax_post({
                    url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=7",
                    data:{
                        bill_goods_no:voucherGoods.bill_goods_no,
                        forget_operate_flow:voucherGoods.forget_operate_flow
                    },
                    call: function( o ){
                        if(o.code == 200){
                            E.alert( response.message,3 ,voucherGoods.execOutBus);
                            //$('#bill_goods_no').val('').focus();
                        }else{
                            //E.alert(o.message);
                            $('#bill_goods_no').val('').focus();
                        }
                    }
                });


                //E.confirm( response.message, voucherGoods.execOutBus, voucherGoods.writeBillGoodsProductError);
            }

        }else { //语音报错
            E.alert(response.message);

 		
            //mod yim.hu 20141119 FUN-BK-0032 切换语音 --start
            	//var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/error.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
            if( voucherGoods.userFlg == 2 && response.code!=4000){
            
            	var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/zhuangtaibuzu.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
            
            }else{
             
             	var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/error.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
            
            }
            
            //mod yim.hu 20141119 FUN-BK-0032 切换语音 --start
            $('#voiceError').html(item);
            //del by 20141117allen.qiang FUN-BK-0031 入库上下车扫描优化 start
            //$('#bill_goods_no').val('').focus();
            //del by 20141117allen.qiang FUN-BK-0031 入库上下车扫描优化 end
            //add by 20141117allen.qiang FUN-BK-0031 入库上下车扫描优化 start
            $('#bill_goods_no').val('');
            $('#hdb').focus();
            //add by 20141117allen.qiang FUN-BK-0031 入库上下车扫描优化 end
        }

    },



    //取消操作
    removeAddLine:function(){
        $('#goods_line_'+voucherGoods.bill_goods_no).remove();
        $('#bill_goods_no').val('').focus();
    },

    //重新加载
    load:function(){
        E.refresh();
        //$('#bill_goods_input').hide();//订单生产流水号部分隐藏
        $('#bill_goods_voucher').hide();//待录入商品信息部分隐藏
    },

    //查看详情 detail第一个参数 1、审核数量  2、打印数 3、入库数 4、上车数 5、下车数 6、未入库 7、未上车 8、未下车
    //详情
    detail: function( para, send_date, distribution_id, send_start_time,send_start_time_end) {
        E.open("/quanliadmin/app/production/warehouseManage.pscript?operFlg=4&para=" + para +"&send_date="+send_date+"&distribution_id="+distribution_id +"&send_start_time="+send_start_time+"&send_start_time_end="+send_start_time_end);
    },


    //跳流程操作下车扫描 信息记录到订单商品漏操作记录表bill_goods_operate_forget
    execOutBus:function(){
        E.ajax_post({
            url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=6",
            data:{
                bill_goods_no:voucherGoods.bill_goods_no,
                forget_operate_flow:voucherGoods.forget_operate_flow
            },
            call: function( o ){
                if(o.code == 200){
                    //E.alert(o.message);
                    $('#bill_goods_no').val('').focus();
                }else{
                    //E.alert(o.message);
                    $('#bill_goods_no').val('').focus();
                }
            }
        });
    },


//    //下车扫描操作
//    execOutBus:function(){
//        E.ajax_post({
//            url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=4",
//            data:{
//                bill_goods_no:voucherGoods.bill_goods_no
//            },
//            call: function( o ) {
//                if(o.code == 200){
//
//                    $('#goods_list').html('');
//                    //==================重新加载获得订单信息start================
//                    var formValues = E.getFormValues("search_form");
//
//                    //查询时把时间记录下来
//                    var send_start_time_detail = $('#send_start_time').val();
//                    var send_start_time_end_detail = $('#send_start_time_end').val();
//                    $('#send_start_time_detail').val(send_start_time_detail);
//                    $('#send_start_time_end_detail').val(send_start_time_end_detail);
//
//                    E.ajax_post({
//                        url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=1&userFlg="+voucherGoods.userFlg,
//                        data:{
//                            formValues:formValues
//                        },
//                        call: "voucherGoods.addLineCallBack" //根据查询信息成功回调函数
//                    });
//
//                    //==================重新加载获得订单信息end================
//
//                    var data =o.data;//返回下车扫描数组
//                    var html = '<tr class = "trData" id="goods_line_' + data[0].bill_goods_no + '">';
//
//                    //当data[0].distribution_technician_audio配送员有值时为下车扫描，且不为空报配送员
//                    if( data[0].distribution_technician_audio){ //自动播放配送员
//
//                        html += '<td style="display: none;"><audio controls="controls" autoplay="autoplay"><source src="' + data[0].distribution_technician_audio + '"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio></td>';
//                    }else{  //自动播放配送站
//                        var Media = document.getElementById("audio");
//                        $('#audio').attr('src',data[0].distribution_audio);
//                        Media.play();
////                        html += '<td style="display: none;"><audio id="audio" controls="controls" autoplay="autoplay" src="' + data[0].distribution_audio + '"></audio></td>';
//                        // html += '<td style="display: none;"><audio controls="controls" autoplay="autoplay"><source src="' + data[0].distribution_audio + '"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio></td>';
//                    }
//
//                    if( voucherGoods.userFlg == 1 || voucherGoods.userFlg == 2){ //质检入库 上车扫描 一个订单多个商品 报语音
//                        if( data[0].billGoods_count > 1){
//
//                            var Media = document.getElementById("audio");
//
//                            Media.addEventListener("ended",voucherGoods.audioPlay, false);
//
//                        }
//                    }
//
//                    html += '<td style="text-align: center;">' + data[0].product_code + '</td>';
//                    html += '<td style="text-align: center;">' + data[0].bill_goods_no + '</td>';
//                    html += '<td>' + data[0].goods_name + '</td>';
//
//                    if( voucherGoods.userFlg == 3 ){
//                        html += '<td>' + data[0].distribution_technicia + '</td>';
//                    }
//                    html += '<td>' + data[0].distribution_name + '</td>';
//                    html += '<td style="text-align: center; ">' + data[0].send_date + '</td>';
//                    html += '<td style="text-align: center;">' + data[0].send_start_time + '</td>';
//                    html += '<td style="text-align: center;">' + data[0].send_end_time + '</td>';
//                    html += '</tr>';
//                    $('#goods_info').prepend( html );
//
//                    //下车扫描显示配送员
//                    $('#distribution_technicia_add').show();
//
//                    $('#lineCount').val(parseInt($('#lineCount').val()) + 1);
//                    $('#goods_line_'+data[0].bill_goods_no).css('background-color','#00ff00');
//
//                    E.alert('下车扫描成功',2);
//
//                    $('#bill_goods_no').val('').focus();
//                }else{ //语音报错
//                    E.alert(o.message);
//                    var item = '<audio controls="controls" autoplay="autoplay"><source src="/quanliadmin/docroot/images/voicePrompt/error.wav"  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
//                    $('#voiceError').html(item);
//                }
//
//            }
//        });
//    },

    writeBillGoodsProductError:function(){ //不下车扫描

        E.ajax_post({
            url: "/invokingAjax-backend/production/voucherGoods.ajax?operFlg=5",
            data:{
                bill_goods_no:voucherGoods.bill_goods_no
            },
            call: function( o ){
                if(o.code == 201){
                    E.alert(o.message);
                    $('#bill_goods_no').val('').focus();
                }else{
                    E.alert(o.message);
                    $('#bill_goods_no').val('').focus();
                }
            }
        });
    },

    audioPlay: function() {
        var Media = document.getElementById("audio");

        $('#audio').attr('src','/quanliadmin/docroot/images/voicePrompt/multicake.wav');
        Media.play();

        Media.removeEventListener("ended",voucherGoods.audioPlay, false );

    }

};
//订单流水号回车事件
$("#bill_goods_no").keydown(function(e){
    if(e.keyCode == 13){
        var bill_goods_no = $.trim($("#bill_goods_no").val());
        if(bill_goods_no == ''){
            global_focus = 'bill_no';
            E.alert('请输入订单商品流水号');
            return false;
        }else{
            voucherGoods.searchBillGoodsInfo( bill_goods_no );
        }
    }
});

//日期控件JS
$('#send_date').datepicker();


$(window).ready(function() {

    $("#cityID").html("");

    var cityHtml = '<option value="">请选择</option>';

    $.ajax({
        type: "post",
        url: "/invokingAjax-comm/bill/distribution.ajax?operFlg=1",
        dataType: "json",
        data: "",
        success: function( result_obj ) {
            if(result_obj.code == 200){
                var selected = "";
                if(result_obj.data.length == 1){
                    selected = "selected";
                }
                $.each(result_obj.data, function(i,val){
                    cityHtml +='<option value="'+val.id+'" '+selected+'>'+val.name+'</option>';
                });
                $('#cityID').html(cityHtml);
                $("#cityID").trigger("change");
            }else{
                E.alert(result_obj.message);
            }
        }
    });


    //点击城市联动获得配送站
    $(document).on('change', '#cityID', function() {

        $('#distribution_id').html("");
        $('#distribution_technician_id').html('');

        var cityID = $('#cityID').children('option:selected').val();
        var distributionHtml = '<option value="">请选择</option>';
        var technicianHtml = '<option value="">请选择</option>';
        $.ajax({
            type: "post",
            url: "/invokingAjax-comm/bill/distribution.ajax?operFlg=2",
            dataType: "json",
            data: {deliver_cityid: cityID},
            success: function( obj ) {
                if(obj.code ==200 && obj.data != null){
                    var selected = "";
                    if(obj.data.length == 1){
                        selected = "selected";
                    }
                    $.each(obj.data, function(i,val){
                        distributionHtml +='<option value="'+val.distribution_id+'" '+selected+'>'+val.distribution_name+'</option>';
                    });
                    $('#distribution_id').html(distributionHtml);
                    $('#distribution_technician_id').html(technicianHtml);
                }else{
                    distributionHtml += '';
                    $('#distribution_id').html(distributionHtml);
                    $('#distribution_technician_id').html(technicianHtml);
                }
            }
        });
    });


});

//$(document).ready(function(){
//    $('#readMore').html('');
//    var Media = document.getElementById("Media");
//    var readMore = '<audio controls="controls" autoplay="autoplay"><source  src=""  type="audio/ogg">您的浏览器不支持 audio 标签。</audio>';
//    if( Media && Media.ended ){
//        $('#readMore').html(readMore);
//    }
//});
</script>

</body>
</html>